package com.yc.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.bean.TestOption;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TestOptionDao extends BaseMapper<TestOption> {
    
    /**
     * 根据题目ID查询选项列表，按顺序排序
     */
    @Select("SELECT * FROM testOptions WHERE questionId = #{questionId} ORDER BY sortOrder ASC")
    List<TestOption> selectByQuestionId(@Param("questionId") Long questionId);
    
    /**
     * 批量查询多个题目的选项
     */
    @Select("<script>" +
            "SELECT * FROM testOptions " +
            "WHERE questionId IN " +
            "<foreach item='id' collection='questionIds' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "ORDER BY questionId ASC, sortOrder ASC" +
            "</script>")
    List<TestOption> selectByQuestionIds(@Param("questionIds") List<Long> questionIds);
} 